package com.hh.test.convert;

import java.text.NumberFormat;

public class ByteToLong {

	public static long convert(byte b) {
		return b;
	}

	public static void main(String[] args) {
		System.out.println(Long.toBinaryString(10000));
		print(LongToBytes(10000));
	}

	static private void print(byte[] bs){
		for(byte b:bs) {
			System.out.print(b+",");
		}
	}
	public static byte[] LongToBytes(long values) {
		byte[] buffer = new byte[8];
		for (int i = 0; i < 8; i++) {
			int offset = 64 - (i + 1) * 8;
			buffer[i] = (byte) ((values >> offset) & 0xff);
		}
		return buffer;
	}

	public static long BytesToLong(byte[] buffer) {
		long values = 0;
		for (int i = 0; i < 8; i++) {
			values <<= 8;
			values |= (buffer[i] & 0xff);
		}
		return values;
	}
}
